﻿using System;
using Alserve.Ffl.Data;

namespace Alserve.Ffl
{
    public class ImportedMatchPlayer:IComparable
    {
        Int32 _espnPlayerId = 0;
        Int32 _clubId = 0;
        Int32 _positionId = 0;
        Boolean _started = false;
        Boolean _playedAsSub = false;
        Int32 _goals = 0;
        Boolean _cleanSheet = false;
        Boolean _concededOne = false;
        Boolean _teamScoredThreePlus = false;

        public ImportedMatchPlayer()
        {
        }

        public Int32 EspnPlayerId
        {
            get { return _espnPlayerId;}
            set 
            { 
                _espnPlayerId = value;
                _PlayerClubView thisPcv = new _PlayerClubView();
                thisPcv.Where.EspnPlayerId.Value = _espnPlayerId;
                if (thisPcv.Query.Load())
                {
                    _clubId = thisPcv.ClubId;
                    _positionId = thisPcv.PositionId;
                }

            }
        }

        public Int32 ClubId
        {
            get { return _clubId; }
        }

        public Int32 PositionId
        {
            get { return _positionId; }
        }

        public Boolean Started
        {
            get { return _started; }
            set { _started = value; }
        }

        public Boolean PlayedAsSub
        {
            get { return _playedAsSub; }
            set { _playedAsSub = value; }
        }

        public Int32 Goals
        {
            get { return _goals; }
            set { _goals = value; }
        }

        public Boolean CleanSheet
        {
            get { return _cleanSheet; }
            set { _cleanSheet = value; }
        }

        public Boolean ConcededOne
        {
            get { return _concededOne; }
            set { _concededOne = value; }
        }

        public Boolean TeamScoredThreePlus
        {
            get { return _teamScoredThreePlus; }
            set { _teamScoredThreePlus = value; }
        }

        public int CompareTo(object obj)
        {
            ImportedMatchPlayer thisImportedMatchPlayer = (ImportedMatchPlayer)obj;

            if (this.ClubId == thisImportedMatchPlayer.ClubId)
                return this.PositionId.CompareTo(thisImportedMatchPlayer.PositionId);
            else
                return this.ClubId.CompareTo(thisImportedMatchPlayer.ClubId);
        }
    }
}